<?php
class ui_reader_action_share extends ui {
	/**
	 * @param object $S
	 * @param array $param	= array (
	 * 			article_id		// save article 的主键id，只有自己保存的文章才能share
	 * 			f			// 好友的uid string
	 * 			c			// 圈子的id string
	 * 			cn			
	 * 			cp			// is private
	 * )
	 */
	public function __construct($S, $param) {
		parent::__construct();
		
		if ($this->uid) {
			if ($param['cn']) {
				$param['cn'] = stripslashes(strip_tags(trim($param['cn'])));
				$param['cp'] = ($param['cp']) ? 'private' : 'public';
				$data_circle = new data_circle();
				$circle_id = $data_circle->add($this->uid, $param['cn'], $param['cp']);
				$param['c'] .= $circle_id;		// 附加最新的circle id，原来的结尾会有一个“,”
			}

			$data_save_article = new data_save_article();
			$data = $data_save_article->in_site_share($this->uid, $param['article_id'], $param['f'], $param['c']);
			
			if ($data) {
				$S->assign('data', 'true');
			} else {
				$S->assign('data', 'false');
			}

		}
	}
}
?>